var fs = require('fs');


function getTime(){
    var time = new Date();
    time = time.toISOString();
    time = time.substring(0,10);
    return time;
}

var controller = {}

controller.uploadFile = function(req, res, next){
    console.log("=====================文件上传分界线=======================");
    console.log(req.file);
    console.log(req);
    var ql = 'insert into content(id,tel,firstnav,secondnav,time,pw,content,filename) values ("upload","' + global.USER_ACCOUNT + '","上传文件","' + req.file.originalname + '","' + getTime() + '","000000","", "'+ req.file.filename +'");'
    console.log(ql);
    conn.query(ql, function(err, results, fields){
        if(err) throw err;
        res.send({
            code: 200
        });
    })
    
}

module.exports = controller;